/**
 * Copyright (C) 2018-2030
 * All rights reserved, Designed By www.samfeng.com
 */

 import {getPage} from '@/api/erp/goodsspu'

export const StockMoveOption = {
  dialogType: 'dialog',
  dialogDrag:true,
  dialogMenuPosition: 'right',
  border: true,
  stripe: true,
  menuAlign: 'center',
  align: 'center',
  menuType: 'text',
  searchShow: true,
  excelBtn: false,
  delBtn:true,
  searchMenuSpan: 6,
  viewBtn: true,
  column: [{
              label: "单据编号",
              prop: "reference",
              display: true,
              type: "table",
              children:{
                border: true,
                showHeader:true,
                searchLabelWidth: 150,
                column: [
                  {
                    label: '',
                    prop: 'id',
                    display: false
                  },
                  {
                    label: '品名',
                    prop: 'name',
                    search: true,
                  }
                ]
              },
              rules: [
                {
                    required: true,
                    message: '不能为空',
                    trigger: 'blur',
                },
             ],
              formatter:(row)=>{
                if(!row.name) return ""
                return row.name;
              },
              onLoad:({page,value,data},callback)=>{
                if(value){
                  console.log("value===", value)                         
                } if(data){
                  console.log("data===", data)  
                }
                else {
                  getPage(Object.assign({
                    current: page.currentPage,
                    size: page.pageSize,
                    descs: "",
                    ascs: "",
                    },{},{})).then(response => {
                      console.log("response===", response)
                      callback({
                        total: response.data.total,
                        data: response.data.records
                      })
                  })
                } 
              },             
          },{
            label: "来源单号",
            prop: "originOrder",
            display: true
          },{
              label: "业务类型",
              prop: "businessTypes",
              type: "tree",
              dicData: [{
                label: '出库',
                value: 'out'
            },{
                label: '入库',
                value: 'in'
            },{
              label: '内部调拨',
              value: 'internal'
          }]
          },{
              label: "确认人",
              prop: "confirmUserId",
              display: true
          },{
              label: "确认时间",
              prop: "confirmTime",
              display: true
          },{
            label: "调拨数量",
            prop: "qtyTotal",
            type: "number"
          },{
              label: "调出仓库1",
              prop: "locationId",
              display: false,
              hide: true
          },{
            label: "调出仓库",
            prop: "locationName",
          },{
              label: "调入仓库1",
              prop: "locationDestId",
              display: false,
              hide: true
          },{
            label: "调入仓库",
            prop: "locationDestName"
          },{
            label: "PK",
            prop: "id",
            display: false,
            hide: true
        }
  ],
  group: [
    {
      icon: '',
      label: '',
      prop: 'group0',
      column: [
        {
          label: "",
          prop: "info",
          hide: true,
          formslot: true,
          span: 5,
          labelWidth: "0"
        }
      ]
    },    
    {
      icon: '',
      label: '',
      prop: 'group1',
      display: true,
      column: [
        {
          label: "",
          prop: "moveLine",
          type: 'dynamic',
          hide: true,
          span: 24,
          labelWidth: "0",
          children: {
            align: 'center',
            type:'form',
            headerAlign: 'center',
            rowAdd:(done)=>{
                done({
                  name:'默认值'
                });
            },
            rowDel:(row,done)=>{
                console.log(row)
              done();
            },
            column: [
              {
                  label: "",
                  prop: "moveId",
                  display: false,
                  hide: true
                },{
                  label: "",
                  prop: "productId",
                  display: false,
                  hide: true
                },{
                  label: "品名",
                  prop: "productName",
                  props: {
                    label: 'name',
                    value: 'id'
                  },
                  type: "table",
                  children:{
                    border: true,
                    showHeader:true,
                    searchLabelWidth: 150,
                    column: [
                      {
                        label: '',
                        prop: 'id',
                        display: false
                      },
                      {
                        label: '品名',
                        prop: 'name',
                        search: true,
                      }
                    ]
                  },
                  rules: [
                    {
                        required: true,
                        message: '不能为空',
                        trigger: 'blur',
                    },
                 ],
                  formatter:(row)=>{
                    return row.name;
                  },
                  onLoad:({page,value,data},callback)=>{
                    if(value){
                      console.log("value===", value)                         
                    } if(data){
                      console.log("data===", data)  
                    }
                    else {
                      getPage(Object.assign({
                        current: page.currentPage,
                        size: page.pageSize,
                        descs: "",
                        ascs: "",
                        },{},{})).then(response => {
                          console.log("response===", response)
                          callback({
                            total: response.data.total,
                            data: response.data.records
                          })
                      })
                    } 
                  },               
                },{
                  label: "数量",
                  prop: "qty",
                },{
                  label: "批次号",
                  prop: "lotName",
                },{
                  label: "操作日期",
                  prop: "operationDate",
                  type: "datetime",
                  format: "yyyy-MM-dd HH:mm:ss",
                  valueFormat: "yyyy-MM-dd HH:mm:ss",
                },{
                  label: "是否完成",
                  prop: "qtyDone",
                  type: "tree",
                  dicData: [{
                    label: '否',
                    value: '0'
                    },{
                        label: '是',
                        value: '1'
                    }]
                },{
                  label: "",
                  prop: "locationId",
                  display: false,
                  hide: true
                },{
                  label: "调出仓",
                  prop: "locationName",
                },{
                  label: "",
                  prop: "locationDestId",
                  display: false,
                  hide: true
                },{
                  label: "调出仓",
                  prop: "locationDestName",
                },{
                  label: "",
                  prop: "businessTypes",
                  display:false,
                  hide: true
                }
            ]
          }
        }
      ]
    },    
    {
      icon: '',
      label: '',
      prop: 'group2',
      display: false,
      column: [
        {
          label: "记账日期",
          prop: "accountDate",
          type: "datetime",
          format: "yyyy-MM-dd HH:mm:ss",
          valueFormat: "yyyy-MM-dd HH:mm:ss",
          
        },{
          label: "申请部门",
          prop: "departmentId"
        },{
          label: "创建时间",
          prop: "createTime",
          disabled: true
        }, {
            label: "修改时间",
            prop: "updateTime",
            disabled: true
        }
      ]    
    },    
  ]
    
}
